//
//  History.h
//  iMed
//
//  Created by Barry Press on 10/9/09.
//  Copyright 2009 Barry Press. All rights reserved.

//	A History element records an event of taking a dose of
//	a medicine. The medicine is specified by the link to the
//	RX, but since what's taken may not match the prescription
//	exactly (e.g., taking a pill cut in half), the actual
//	dose and quantity have to be recorded here. 

//

#import <Foundation/Foundation.h>
#import "RX.h"


@interface History : NSObject <NSCoding, NSCopying> {
	RX*				rx;						// Link to the RX
	float			rxcount;				// How many of them taken
	float			dose;					// Modifier of the RX dose (e.g., .5)
	NSDate*			timestamp;				// Datetime when dose taken
	NSDate*			priorrx;				// previous time this RX was taken
	NSTimeInterval	interval;				// How long since previous dose
	NSTimeInterval	runninginterval;		// Average interval this day to now
}

- (id)initWithRX:(RX*)arx withDose:(float)adose Count:(float)acount atTime:(NSDate*)adate;
- (id)initWithRX:(RX*)arx withDose:(float)adose Count:(float)acount 
		  atTime:(NSDate*)adate returningPriorHistory:(History**)priorHistory;
- (BOOL)isForRX:(RX*)aRX;


@property (readwrite, retain) RX* rx;
@property (readwrite) float rxcount;
@property (readwrite) float dose;
@property (readwrite, retain) NSDate* timestamp;
@property (readwrite, retain) NSDate* priorrx;
@property (readwrite) NSTimeInterval interval;
@property (readwrite) NSTimeInterval runninginterval;

@end
